<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    function addBigNumbers(a, b) {
        let carry = 0;  // 进位值
        let result = ""; // 最终的结果字符串
        const maxLength = Math.max(a.length, b.length); // 取两个数字中较长的位数
        // 用 padStart 补零让两数字位数一样长，便于从右往左逐位处理。
        a = a.padStart(maxLength, "0");
        b = b.padStart(maxLength, "0");

        for (let i = maxLength - 1; i >= 0; i--) {
            const sum = parseInt(a[i]) + parseInt(b[i]) + carry;
            carry = Math.floor(sum / 10);  // 计算进位
            result = (sum % 10) + result; // 当前位 + 拼接到前面
        }

        if (carry) result = carry + result;
        
        return result;
    }

        console.log(addBigNumbers("9007199254740993", "1")); // "9007199254740994"
</script>
</html>